import miniGameSdk from './src/miniGameSdk';
import commons from './src/commons/commons';

const app = new miniGameSdk()

function init(params, cb) {
    let now = commons.formatDate(new Date(), 'YmdHis.u')
    console.log('[SDK DEBUG]['+now+']', '调用init', JSON.stringify(params))
    app.init(params, cb)
}

function login(params, cb) {
    app.printDebug('调用login', params)
    app.login(params, cb)
}

function pay(params, cb) {
    app.printDebug('调用pay', params)
    app.pay(params, cb)
}

function showModal(params, cb) {
    app.printDebug('调用showModal', params)
    app.showModal(params, cb)
}

function goKefu(params, cb) {
    app.printDebug('调用goKefu')
    app.goKefu(params, cb)
}

function msgSecCheck(params, cb) {
    app.printDebug('调用msgSecCheck', params)
    app.msgSecCheck(params, cb)
}

function roleReg(params, cb) {
    app.printDebug('调用roleReg', params)
    app.roleReg(params, cb)
}

function roleLogin(params, cb) {
    app.printDebug('调用roleLogin', params)
    app.roleLogin(params, cb)
}

function roleEvent(params, cb) {
    app.printDebug('调用roleEvent', params)
    app.roleEvent(params, cb)
}

// 监听小游戏热启动时
wx.onShow((info) => {
    app.printDebug('监听到onshow', info)
    app.initOnShow(info)
    app.addLog(1001, 'onshow', {})
})

export default {
    init,
    login,
    pay,
    showModal,
    goKefu,
    msgSecCheck,
    roleReg,
    roleLogin,
    roleEvent
}
